ScaleFusion
传入一个数组,逐元素乘上因数,并加上偏置的值后输出。
\[dst_i = src_i \cdot scale_i + bias_i\]
- 输入:
src_data - 输入数据地址。
length - 计算长度。
scale - 缩放因子数组首地址。
bias - 偏置数组首地址。
core_mask - 核掩码(仅适用于共享存储版本)。
- 输出:
dst_data - 计算结果地址。
- 支持平台:
FT78NEMT7004备注
FT78NE 支持int8, int16, int32, fp32, fp64
MT7004 支持fp16, fp32, int16, int32
共享存储版本:
-
void i8_scalefusion_s(int8_t *src_data, int8_t *dst_data, int length, float *scale, float *bias, int core_mask)
-
void i16_scalefusion_s(int16_t *src_data, int16_t *dst_data, int length, float *scale, float *bias, int core_mask)
-
void i32_scalefusion_s(int *src_data, int *dst_data, int length, float *scale, float *bias, int core_mask)
-
void hp_scalefusion_s(half *src_data, half *dst_data, int length, half *scale, half *bias, int core_mask)
-
void fp_scalefusion_s(float *src_data, float *dst_data, int length, float *scale, float *bias, int core_mask)
-
void dp_scalefusion_s(double *src_data, double *dst_data, int length, double *scale, double *bias, int core_mask)
C调用示例:
1//FT78NE示例 2#include <stdio.h> 3#include <scalefusion.h> 4 5int main(int argc, char* argv[]) { 6 float *input0 = (float *)0xA0000000; //input在DDR空间 7 float *output = (float *)0xC0000000; 8 float *scale = (float *)0xB0000000; //scale在DDR空间 9 float *bias = (float *)0xB1000000; //bias在DDR空间 10 int length = 1000; 11 int core_mask = 0xff; 12 fp_scalefusion_s( input0, output, length, scale, bias, core_mask); 13 return 0; 14}
私有存储版本:
-
void i8_scalefusion_p(int8_t *src_data, int8_t *dst_data, int length, float *scale, float *bias)
-
void i16_scalefusion_p(int16_t *src_data, int16_t *dst_data, int length, float *scale, float *bias)
-
void i32_scalefusion_p(int *src_data, int *dst_data, int length, float *scale, float *bias)
-
void hp_scalefusion_p(half *src_data, half *dst_data, int length, half *scale, half *bias)
-
void fp_scalefusion_p(float *src_data, float *dst_data, int length, float *scale, float *bias)
-
void dp_scalefusion_p(double *src_data, double *dst_data, int length, double *scale, double *bias)
C调用示例:
1//FT78NE示例 2#include <stdio.h> 3#include <scalefusion.h> 4int main(int argc, char* argv[]) { 5 float *input0 = (float *)0x10810000; //input在L2空间 6 float *output = (float *)0x10820000; 7 float *scale = (float *)0x10830000; //scale在L2空间 8 float *bias = (float *)0x10840000; //bias在L2空间 9 int length = 1000; 10 fp_scalefusion_p( input0, output, length, scale, bias); 11 return 0; 12}